
const _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault');

exports.__esModule = true;
exports.default = void 0;

const _utils = require('../utils');

const _Network = _interopRequireDefault(require('./Network'));

const _createNamespace = (0, _utils.createNamespace)('empty');
const createComponent = _createNamespace[0];
const bem = _createNamespace[1];

const PRESETS = ['error', 'search', 'default'];

const _default = createComponent({
  props: {
    description: String,
    image: {
      type: String,
      default: 'default',
    },
  },
  methods: {
    genImageContent: function genImageContent() {
      const h = this.$createElement;
      const slots = this.slots('image');

      if (slots) {
        return slots;
      }

      if (this.image === 'network') {
        return h(_Network.default);
      }

      let { image } = this;

      if (PRESETS.indexOf(image) !== -1) {
        image = `https://img.yzcdn.cn/vant/empty-image-${image}.png`;
      }

      return h('img', {
        attrs: {
          src: image,
        },
      });
    },
    genImage: function genImage() {
      const h = this.$createElement;
      return h('div', {
        class: bem('image'),
      }, [this.genImageContent()]);
    },
    genDescription: function genDescription() {
      const h = this.$createElement;
      const description = this.slots('description') || this.description;

      if (description) {
        return h('p', {
          class: bem('description'),
        }, [description]);
      }
    },
    genBottom: function genBottom() {
      const h = this.$createElement;
      const slot = this.slots();

      if (slot) {
        return h('div', {
          class: bem('bottom'),
        }, [slot]);
      }
    },
  },
  render: function render() {
    const h = arguments[0];
    return h('div', {
      class: bem(),
    }, [this.genImage(), this.genDescription(), this.genBottom()]);
  },
});

exports.default = _default;
